﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<UserControl x:Class="System.Windows.Controls.Samples.TransitioningContentControlSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples">
  <UserControl.Resources>
    <Style x:Key="tccUpDown" TargetType="layoutToolkit:TransitioningContentControl">
      <Setter Property="IsTabStop" Value="True" />
      <Setter Property="HorizontalContentAlignment" Value="Left" />
      <Setter Property="VerticalContentAlignment" Value="Top" />
      <Setter Property="Transition" Value="DefaultTransition" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="layoutToolkit:TransitioningContentControl">
            <Border
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="2">
              <vsm:VisualStateManager.VisualStateGroups>
                <vsm:VisualStateGroup x:Name="PresentationStates">
                  <vsm:VisualState x:Name="DefaultTransition">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames 
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="CurrentContentPresentationSite"
                      Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="PreviousContentPresentationSite" 
                      Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </vsm:VisualState>
                  <vsm:VisualState x:Name="Normal">
                    <Storyboard>
                      <ObjectAnimationUsingKeyFrames 
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="PreviousContentPresentationSite" 
                      Storyboard.TargetProperty="(UIElement.Visibility)">
                        <DiscreteObjectKeyFrame KeyTime="00:00:00">
                          <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                          </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                      </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                  </vsm:VisualState>

                  <vsm:VisualState x:Name="UpTransition">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="30"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="-30"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </vsm:VisualState>

                  <vsm:VisualState x:Name="DownTransition">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-40"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>

                      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="40"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </vsm:VisualState>

                </vsm:VisualStateGroup>
              </vsm:VisualStateManager.VisualStateGroups>

              <Grid>
                <ContentPresenter
                  x:Name="PreviousContentPresentationSite"
                  Content="{x:Null}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                  <ContentPresenter.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform />
                      <SkewTransform />
                      <RotateTransform />
                      <TranslateTransform />
                    </TransformGroup>
                  </ContentPresenter.RenderTransform>
                </ContentPresenter>
                <ContentPresenter
                  x:Name="CurrentContentPresentationSite"
                  Content="{x:Null}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                  <ContentPresenter.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform />
                      <SkewTransform />
                      <RotateTransform />
                      <TranslateTransform />
                    </TransformGroup>
                  </ContentPresenter.RenderTransform>
                </ContentPresenter>
              </Grid>
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    
    <ControlTemplate x:Key="DUDWithTransitioningContent" TargetType="inputToolkit:DomainUpDown">
      <Grid x:Name="RootElement">
        <vsm:VisualStateManager.VisualStateGroups>
          <!-- common states -->
          <vsm:VisualStateGroup x:Name="CommonStates">
            <vsm:VisualState x:Name="Normal"/>
            <vsm:VisualState x:Name="MouseOver">
              <Storyboard>
                <ColorAnimationUsingKeyFrames 
                      Storyboard.TargetName="MouseOverBorder" 
                      Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                  <SplineColorKeyFrame KeyTime="0" Value="#FF99C1E2"/>
                </ColorAnimationUsingKeyFrames>
              </Storyboard>
            </vsm:VisualState>
            <vsm:VisualState x:Name="Disabled">
              <Storyboard>
                <DoubleAnimationUsingKeyFrames 
                      Storyboard.TargetName="DisabledVisualElement" 
                      Storyboard.TargetProperty="Opacity">
                  <SplineDoubleKeyFrame 
                        KeyTime="0" 
                        Value="1"/>
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
            </vsm:VisualState>
          </vsm:VisualStateGroup>
          <!-- focus states -->
          <vsm:VisualStateGroup x:Name="FocusStates">
            <vsm:VisualState x:Name="Focused">
              <Storyboard>
                <DoubleAnimationUsingKeyFrames 
                      Storyboard.TargetName="FocusVisualElement" 
                      Storyboard.TargetProperty="Opacity">
                  <SplineDoubleKeyFrame
                        KeyTime="0"
                        Value="1" />
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
            </vsm:VisualState>
            <vsm:VisualState x:Name="Unfocused">
              <Storyboard>
                <DoubleAnimationUsingKeyFrames
                      Storyboard.TargetName="FocusVisualElement"
                      Storyboard.TargetProperty="Opacity">
                  <SplineDoubleKeyFrame
                        KeyTime="0"
                        Value="0" />
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
            </vsm:VisualState>
          </vsm:VisualStateGroup>
          <!-- interaction mode states -->
          <vsm:VisualStateGroup x:Name="InteractionModeStates">
            <vsm:VisualState x:Name="Edit">
              <Storyboard>
                <DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Text" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="1"/>
                <DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Visualization" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="0"/>
              </Storyboard>
            </vsm:VisualState>
            <vsm:VisualState x:Name="Display">
            </vsm:VisualState>
          </vsm:VisualStateGroup>
          <!-- input valid states -->
          <vsm:VisualStateGroup x:Name="DomainStates">
            <vsm:VisualState x:Name="ValidDomain">
            </vsm:VisualState>
            <vsm:VisualState x:Name="InvalidDomain">
              <Storyboard>
                <ObjectAnimationUsingKeyFrames 
                      Storyboard.TargetName="ErrorVisualElement" 
                      Storyboard.TargetProperty="(UIElement.Visibility)" 
                      Duration="0">
                  <DiscreteObjectKeyFrame 
                        KeyTime="0" 
                        Value="Visible" />
                </ObjectAnimationUsingKeyFrames>
              </Storyboard>
            </vsm:VisualState>
          </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>

        <Border 
              x:Name="Border" 
              Opacity="1" 
              Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}" 
              BorderThickness="{TemplateBinding BorderThickness}" 
              CornerRadius="1">
          <Grid>
            <Border 
                  x:Name="MouseOverBorder" 
                  BorderBrush="Transparent" 
                  BorderThickness="1">
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*"/>
                  <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Grid Margin="{TemplateBinding Padding}">
                  <layoutToolkit:TransitioningContentControl
                        x:Name="Visualization"
                        Style="{StaticResource tccUpDown}"
                        Margin="0" 
                        Padding="0"
                        IsTabStop="False"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        Content="{TemplateBinding Value}"
                        ContentTemplate="{TemplateBinding ItemTemplate}"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        Foreground="{TemplateBinding Foreground}" />
                  <TextBox 
                        x:Name="Text" 
                        Opacity="0" 
                        Margin="0" 
                        Padding="0"
                        IsTabStop="True"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        BorderThickness="0"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        Foreground="{TemplateBinding Foreground}"
                        AcceptsReturn="False" 
                        IsHitTestVisible="false"
                        TextWrapping="NoWrap" >
                    <TextBox.Style>
                      <Style TargetType="TextBox">
                        <Setter Property="Template">
                          <Setter.Value>
                            <ControlTemplate TargetType="TextBox">
                              <ScrollViewer
                                    x:Name="ContentElement"
                                    Padding="0"
                                    IsHitTestVisible="false"
                                    BorderThickness="0" />
                            </ControlTemplate>
                          </Setter.Value>
                        </Setter>
                      </Style>
                    </TextBox.Style>
                  </TextBox>
                </Grid>
                <inputToolkit:ButtonSpinner
                      x:Name="Spinner"
                      IsTabStop="False"
                      TabIndex="3"
                      Grid.Column="1" />
              </Grid>
            </Border>
          </Grid>
        </Border>
        <Border
              x:Name="DisabledVisualElement"
              IsHitTestVisible="False"
              Opacity="0"
              Background="#A5F7F7F7"
              BorderBrush="#A5F7F7F7"
              BorderThickness="{TemplateBinding BorderThickness}" />
        <Border
              x:Name="FocusVisualElement"
              Margin="1"
              IsHitTestVisible="False"
              Opacity="0"
              BorderBrush="#FF6DBDD1"
              BorderThickness="{TemplateBinding BorderThickness}" />
        <Border
              x:Name="ErrorVisualElement"
              CornerRadius="1"
              Visibility="Collapsed"
              Margin="-2"
              IsHitTestVisible="False"
              BorderBrush="Red"
              BorderThickness="2" />
      </Grid>
    </ControlTemplate>


  </UserControl.Resources>
  
  <StackPanel Background="White">
    <ContentControl Content="Up Down Transitions" Style="{StaticResource Header}" />
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="220" />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>
      <layoutToolkit:TransitioningContentControl x:Name="defaultTCC"
                                                 Style="{StaticResource tccUpDown}"
                                                 Grid.Column="0" 
                                                 Content="Press buttons to change content" 
                                                 HorizontalAlignment="Left" />
      <Button Content="Default" Click="ChangeContentSample1" Grid.Column="1" Margin="3" />
      <Button Content="Up" Click="ChangeContentSample1Up" Grid.Column="2" Margin="3" />
      <Button Content="Down" Click="ChangeContentSample1Down" Grid.Column="3" Margin="3" />
    </Grid>
    
    <ContentControl Content="DomainUpDown scenario" Style="{StaticResource Header}" />
    <samples:TransitioningDomainUpDown 
      x:Name="dud" 
      Height="Auto" 
      IsEditable="False" 
      Template="{StaticResource DUDWithTransitioningContent}" >
      <samples:TransitioningDomainUpDown.ItemTemplate>
        <DataTemplate>
          <Grid MinWidth="370">
            <Grid.Background>
              <SolidColorBrush Color="#aa000000" />
            </Grid.Background>
            <TextBlock
              Foreground="#22ffffff"
              Margin="4+0,2+0"
              FontSize="34"
              Text="{Binding CodeFaa}" />
            <StackPanel
              HorizontalAlignment="Right"
              Margin="0, 0, 8, 0">
              <TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="12"
                Text="{Binding LimitedName}"
                Padding="2" />
              <TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="14"
                Text="{Binding City}"
                Padding="2" />
              <TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="14"
                Text="{Binding State}"
                Padding="2" />
            </StackPanel>
          </Grid>
        </DataTemplate>
      </samples:TransitioningDomainUpDown.ItemTemplate>
    </samples:TransitioningDomainUpDown>

    <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="TransitioningContentControlSample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;

&lt;UserControl x:Class="System.Windows.Controls.Samples.TransitioningContentControlSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples"&gt;
  &lt;UserControl.Resources&gt;
    &lt;Style x:Key="tccUpDown" TargetType="layoutToolkit:TransitioningContentControl"&gt;
      &lt;Setter Property="IsTabStop" Value="True" /&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="Left" /&gt;
      &lt;Setter Property="VerticalContentAlignment" Value="Top" /&gt;
      &lt;Setter Property="Transition" Value="DefaultTransition" /&gt;
      &lt;Setter Property="Template"&gt;
        &lt;Setter.Value&gt;
          &lt;ControlTemplate TargetType="layoutToolkit:TransitioningContentControl"&gt;
            &lt;Border
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="2"&gt;
              &lt;vsm:VisualStateManager.VisualStateGroups&gt;
                &lt;vsm:VisualStateGroup x:Name="PresentationStates"&gt;
                  &lt;vsm:VisualState x:Name="DefaultTransition"&gt;
                    &lt;Storyboard&gt;
                      &lt;DoubleAnimationUsingKeyFrames 
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="CurrentContentPresentationSite"
                      Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;
                      &lt;DoubleAnimationUsingKeyFrames
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="PreviousContentPresentationSite" 
                      Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;
                    &lt;/Storyboard&gt;
                  &lt;/vsm:VisualState&gt;
                  &lt;vsm:VisualState x:Name="Normal"&gt;
                    &lt;Storyboard&gt;
                      &lt;ObjectAnimationUsingKeyFrames 
                      BeginTime="00:00:00" 
                      Storyboard.TargetName="PreviousContentPresentationSite" 
                      Storyboard.TargetProperty="(UIElement.Visibility)"&gt;
                        &lt;DiscreteObjectKeyFrame KeyTime="00:00:00"&gt;
                          &lt;DiscreteObjectKeyFrame.Value&gt;
                            &lt;Visibility&gt;Collapsed&lt;/Visibility&gt;
                          &lt;/DiscreteObjectKeyFrame.Value&gt;
                        &lt;/DiscreteObjectKeyFrame&gt;
                      &lt;/ObjectAnimationUsingKeyFrames&gt;
                    &lt;/Storyboard&gt;
                  &lt;/vsm:VisualState&gt;

                  &lt;vsm:VisualState x:Name="UpTransition"&gt;
                    &lt;Storyboard&gt;
                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="30"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="-30"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;
                    &lt;/Storyboard&gt;
                  &lt;/vsm:VisualState&gt;

                  &lt;vsm:VisualState x:Name="DownTransition"&gt;
                    &lt;Storyboard&gt;
                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="1"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="-40"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;

                      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt;
                        &lt;SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="40"/&gt;
                      &lt;/DoubleAnimationUsingKeyFrames&gt;
                    &lt;/Storyboard&gt;
                  &lt;/vsm:VisualState&gt;

                &lt;/vsm:VisualStateGroup&gt;
              &lt;/vsm:VisualStateManager.VisualStateGroups&gt;

              &lt;Grid&gt;
                &lt;ContentPresenter
                  x:Name="PreviousContentPresentationSite"
                  Content="{x:Null}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"&gt;
                  &lt;ContentPresenter.RenderTransform&gt;
                    &lt;TransformGroup&gt;
                      &lt;ScaleTransform /&gt;
                      &lt;SkewTransform /&gt;
                      &lt;RotateTransform /&gt;
                      &lt;TranslateTransform /&gt;
                    &lt;/TransformGroup&gt;
                  &lt;/ContentPresenter.RenderTransform&gt;
                &lt;/ContentPresenter&gt;
                &lt;ContentPresenter
                  x:Name="CurrentContentPresentationSite"
                  Content="{x:Null}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"&gt;
                  &lt;ContentPresenter.RenderTransform&gt;
                    &lt;TransformGroup&gt;
                      &lt;ScaleTransform /&gt;
                      &lt;SkewTransform /&gt;
                      &lt;RotateTransform /&gt;
                      &lt;TranslateTransform /&gt;
                    &lt;/TransformGroup&gt;
                  &lt;/ContentPresenter.RenderTransform&gt;
                &lt;/ContentPresenter&gt;
              &lt;/Grid&gt;
            &lt;/Border&gt;
          &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
    &lt;/Style&gt;
    
    &lt;ControlTemplate x:Key="DUDWithTransitioningContent" TargetType="inputToolkit:DomainUpDown"&gt;
      &lt;Grid x:Name="RootElement"&gt;
        &lt;vsm:VisualStateManager.VisualStateGroups&gt;
          &lt;!-- common states --&gt;
          &lt;vsm:VisualStateGroup x:Name="CommonStates"&gt;
            &lt;vsm:VisualState x:Name="Normal"/&gt;
            &lt;vsm:VisualState x:Name="MouseOver"&gt;
              &lt;Storyboard&gt;
                &lt;ColorAnimationUsingKeyFrames 
                      Storyboard.TargetName="MouseOverBorder" 
                      Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"&gt;
                  &lt;SplineColorKeyFrame KeyTime="0" Value="#FF99C1E2"/&gt;
                &lt;/ColorAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
            &lt;vsm:VisualState x:Name="Disabled"&gt;
              &lt;Storyboard&gt;
                &lt;DoubleAnimationUsingKeyFrames 
                      Storyboard.TargetName="DisabledVisualElement" 
                      Storyboard.TargetProperty="Opacity"&gt;
                  &lt;SplineDoubleKeyFrame 
                        KeyTime="0" 
                        Value="1"/&gt;
                &lt;/DoubleAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
          &lt;/vsm:VisualStateGroup&gt;
          &lt;!-- focus states --&gt;
          &lt;vsm:VisualStateGroup x:Name="FocusStates"&gt;
            &lt;vsm:VisualState x:Name="Focused"&gt;
              &lt;Storyboard&gt;
                &lt;DoubleAnimationUsingKeyFrames 
                      Storyboard.TargetName="FocusVisualElement" 
                      Storyboard.TargetProperty="Opacity"&gt;
                  &lt;SplineDoubleKeyFrame
                        KeyTime="0"
                        Value="1" /&gt;
                &lt;/DoubleAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
            &lt;vsm:VisualState x:Name="Unfocused"&gt;
              &lt;Storyboard&gt;
                &lt;DoubleAnimationUsingKeyFrames
                      Storyboard.TargetName="FocusVisualElement"
                      Storyboard.TargetProperty="Opacity"&gt;
                  &lt;SplineDoubleKeyFrame
                        KeyTime="0"
                        Value="0" /&gt;
                &lt;/DoubleAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
          &lt;/vsm:VisualStateGroup&gt;
          &lt;!-- interaction mode states --&gt;
          &lt;vsm:VisualStateGroup x:Name="InteractionModeStates"&gt;
            &lt;vsm:VisualState x:Name="Edit"&gt;
              &lt;Storyboard&gt;
                &lt;DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Text" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="1"/&gt;
                &lt;DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Visualization" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="0"/&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
            &lt;vsm:VisualState x:Name="Display"&gt;
            &lt;/vsm:VisualState&gt;
          &lt;/vsm:VisualStateGroup&gt;
          &lt;!-- input valid states --&gt;
          &lt;vsm:VisualStateGroup x:Name="DomainStates"&gt;
            &lt;vsm:VisualState x:Name="ValidDomain"&gt;
            &lt;/vsm:VisualState&gt;
            &lt;vsm:VisualState x:Name="InvalidDomain"&gt;
              &lt;Storyboard&gt;
                &lt;ObjectAnimationUsingKeyFrames 
                      Storyboard.TargetName="ErrorVisualElement" 
                      Storyboard.TargetProperty="(UIElement.Visibility)" 
                      Duration="0"&gt;
                  &lt;DiscreteObjectKeyFrame 
                        KeyTime="0" 
                        Value="Visible" /&gt;
                &lt;/ObjectAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
            &lt;/vsm:VisualState&gt;
          &lt;/vsm:VisualStateGroup&gt;
        &lt;/vsm:VisualStateManager.VisualStateGroups&gt;

        &lt;Border 
              x:Name="Border" 
              Opacity="1" 
              Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}" 
              BorderThickness="{TemplateBinding BorderThickness}" 
              CornerRadius="1"&gt;
          &lt;Grid&gt;
            &lt;Border 
                  x:Name="MouseOverBorder" 
                  BorderBrush="Transparent" 
                  BorderThickness="1"&gt;
              &lt;Grid&gt;
                &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
                &lt;/Grid.ColumnDefinitions&gt;

                &lt;Grid Margin="{TemplateBinding Padding}"&gt;
                  &lt;layoutToolkit:TransitioningContentControl
                        x:Name="Visualization"
                        Style="{StaticResource tccUpDown}"
                        Margin="0" 
                        Padding="0"
                        IsTabStop="False"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        Content="{TemplateBinding Value}"
                        ContentTemplate="{TemplateBinding ItemTemplate}"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        Foreground="{TemplateBinding Foreground}" /&gt;
                  &lt;TextBox 
                        x:Name="Text" 
                        Opacity="0" 
                        Margin="0" 
                        Padding="0"
                        IsTabStop="True"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        BorderThickness="0"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        Foreground="{TemplateBinding Foreground}"
                        AcceptsReturn="False" 
                        IsHitTestVisible="false"
                        TextWrapping="NoWrap" &gt;
                    &lt;TextBox.Style&gt;
                      &lt;Style TargetType="TextBox"&gt;
                        &lt;Setter Property="Template"&gt;
                          &lt;Setter.Value&gt;
                            &lt;ControlTemplate TargetType="TextBox"&gt;
                              &lt;ScrollViewer
                                    x:Name="ContentElement"
                                    Padding="0"
                                    IsHitTestVisible="false"
                                    BorderThickness="0" /&gt;
                            &lt;/ControlTemplate&gt;
                          &lt;/Setter.Value&gt;
                        &lt;/Setter&gt;
                      &lt;/Style&gt;
                    &lt;/TextBox.Style&gt;
                  &lt;/TextBox&gt;
                &lt;/Grid&gt;
                &lt;inputToolkit:ButtonSpinner
                      x:Name="Spinner"
                      IsTabStop="False"
                      TabIndex="3"
                      Grid.Column="1" /&gt;
              &lt;/Grid&gt;
            &lt;/Border&gt;
          &lt;/Grid&gt;
        &lt;/Border&gt;
        &lt;Border
              x:Name="DisabledVisualElement"
              IsHitTestVisible="False"
              Opacity="0"
              Background="#A5F7F7F7"
              BorderBrush="#A5F7F7F7"
              BorderThickness="{TemplateBinding BorderThickness}" /&gt;
        &lt;Border
              x:Name="FocusVisualElement"
              Margin="1"
              IsHitTestVisible="False"
              Opacity="0"
              BorderBrush="#FF6DBDD1"
              BorderThickness="{TemplateBinding BorderThickness}" /&gt;
        &lt;Border
              x:Name="ErrorVisualElement"
              CornerRadius="1"
              Visibility="Collapsed"
              Margin="-2"
              IsHitTestVisible="False"
              BorderBrush="Red"
              BorderThickness="2" /&gt;
      &lt;/Grid&gt;
    &lt;/ControlTemplate&gt;


  &lt;/UserControl.Resources&gt;
  
  &lt;StackPanel Background="White"&gt;
    &lt;ContentControl Content="Up Down Transitions" Style="{StaticResource Header}" /&gt;
    &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition Width="220" /&gt;
        &lt;ColumnDefinition /&gt;
        &lt;ColumnDefinition /&gt;
        &lt;ColumnDefinition /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;layoutToolkit:TransitioningContentControl x:Name="defaultTCC"
                                                 Style="{StaticResource tccUpDown}"
                                                 Grid.Column="0" 
                                                 Content="Press buttons to change content" 
                                                 HorizontalAlignment="Left" /&gt;
      &lt;Button Content="Default" Click="ChangeContentSample1" Grid.Column="1" Margin="3" /&gt;
      &lt;Button Content="Up" Click="ChangeContentSample1Up" Grid.Column="2" Margin="3" /&gt;
      &lt;Button Content="Down" Click="ChangeContentSample1Down" Grid.Column="3" Margin="3" /&gt;
    &lt;/Grid&gt;
    
    &lt;ContentControl Content="DomainUpDown scenario" Style="{StaticResource Header}" /&gt;
    &lt;samples:TransitioningDomainUpDown 
      x:Name="dud" 
      Height="Auto" 
      IsEditable="False" 
      Template="{StaticResource DUDWithTransitioningContent}" &gt;
      &lt;samples:TransitioningDomainUpDown.ItemTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;Grid MinWidth="370"&gt;
            &lt;Grid.Background&gt;
              &lt;SolidColorBrush Color="#aa000000" /&gt;
            &lt;/Grid.Background&gt;
            &lt;TextBlock
              Foreground="#22ffffff"
              Margin="4+0,2+0"
              FontSize="34"
              Text="{Binding CodeFaa}" /&gt;
            &lt;StackPanel
              HorizontalAlignment="Right"
              Margin="0, 0, 8, 0"&gt;
              &lt;TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="12"
                Text="{Binding LimitedName}"
                Padding="2" /&gt;
              &lt;TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="14"
                Text="{Binding City}"
                Padding="2" /&gt;
              &lt;TextBlock
                HorizontalAlignment="Right"
                Foreground="White"
                FontSize="14"
                Text="{Binding State}"
                Padding="2" /&gt;
            &lt;/StackPanel&gt;
          &lt;/Grid&gt;
        &lt;/DataTemplate&gt;
      &lt;/samples:TransitioningDomainUpDown.ItemTemplate&gt;
    &lt;/samples:TransitioningDomainUpDown&gt;
  &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="TransitioningContentControlSample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample for the experimental control: TransitioningContentControl.
    /// &lt;/summary&gt;
    /// &lt;QualityBand&gt;Experimental&lt;/QualityBand&gt;
    [Sample("TransitioningContentControl", DifficultyLevel.Basic)]
    [Category("TransitioningContentControl")]
    public partial class TransitioningContentControlSample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref="TransitioningContentControlSample"/&gt; class.
        /// &lt;/summary&gt;
        public TransitioningContentControlSample()
        {
            InitializeComponent();

            Loaded += (sender, e) =&gt; dud.ItemsSource = Airport.SampleAirports;
        }

        /// &lt;summary&gt;
        /// Changes the content with the default transition.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by Xaml.")]
        private void ChangeContentSample1(object sender, RoutedEventArgs e)
        {
            defaultTCC.Transition = TransitioningContentControl.DefaultTransitionState;
            defaultTCC.Content = DateTime.Now.Ticks;
        }

        /// &lt;summary&gt;
        /// Changes the content with the down transition.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by Xaml.")]
        private void ChangeContentSample1Down(object sender, RoutedEventArgs e)
        {
            defaultTCC.Transition = "DownTransition";
            defaultTCC.Content = DateTime.Now.Ticks;
        }

        /// &lt;summary&gt;
        /// Changes the content up transition.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by Xaml.")]
        private void ChangeContentSample1Up(object sender, RoutedEventArgs e)
        {
            defaultTCC.Transition = "UpTransition";
            defaultTCC.Content = DateTime.Now.Ticks;
        }
    }
}</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="TransitioningContentControlSample.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports Microsoft.VisualBasic
Imports System.ComponentModel
Imports System.Diagnostics.CodeAnalysis

''' &lt;summary&gt;
''' Sample for the experimental control: TransitioningContentControl.
''' &lt;/summary&gt;
''' &lt;QualityBand&gt;Experimental&lt;/QualityBand&gt;
&lt;Sample("TransitioningContentControl", DifficultyLevel.Basic), Category("TransitioningContentControl")&gt; _
Partial Public Class TransitioningContentControlSample
    Inherits UserControl
    ''' &lt;summary&gt;
    ''' Initializes a new instance of the &lt;see cref="TransitioningContentControlSample"/&gt; class.
    ''' &lt;/summary&gt;
    Public Sub New()
        InitializeComponent()
    End Sub

    ''' &lt;summary&gt;
    ''' Handles the Loaded event.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    Private Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles Me.Loaded
        dud.ItemsSource = Airport.SampleAirports
    End Sub

    ''' &lt;summary&gt;
    ''' Changes the content with the default transition.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Used by Xaml.")&gt; _
    Private Sub ChangeContentSample1(ByVal sender As Object, ByVal e As RoutedEventArgs)
        defaultTCC.Transition = TransitioningContentControl.DefaultTransitionState
        defaultTCC.Content = DateTime.Now.Ticks
    End Sub

    ''' &lt;summary&gt;
    ''' Changes the content with the down transition.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Used by Xaml.")&gt; _
    Private Sub ChangeContentSample1Down(ByVal sender As Object, ByVal e As RoutedEventArgs)
        defaultTCC.Transition = "DownTransition"
        defaultTCC.Content = DateTime.Now.Ticks
    End Sub

    ''' &lt;summary&gt;
    ''' Changes the content up transition.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Used by Xaml.")&gt; _
    Private Sub ChangeContentSample1Up(ByVal sender As Object, ByVal e As RoutedEventArgs)
        defaultTCC.Transition = "UpTransition"
        defaultTCC.Content = DateTime.Now.Ticks
    End Sub
End Class</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="TransitioningDomainUpDown.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Implementation of DomainUpDown that uses a TransitioningContentControl
    /// it its template.
    /// &lt;/summary&gt;
    /// &lt;QualityBand&gt;Experimental&lt;/QualityBand&gt;
    /// &lt;remarks&gt;Implemented in the sample project. The sample page will set
    /// the custom template that this control expects.&lt;/remarks&gt;
    public class TransitioningDomainUpDown : DomainUpDown
    {
        /// &lt;summary&gt;
        /// The name of the state that represents a transition effect upwards.
        /// &lt;/summary&gt;
        public const string UpTransitionState = "UpTransition";

        /// &lt;summary&gt;
        /// The name of the state that represents a transition effect downwards.
        /// &lt;/summary&gt;
        public const string DownTransitionState = "DownTransition";

        /// &lt;summary&gt;
        /// Gets or sets the transition element.
        /// &lt;/summary&gt;
        /// &lt;value&gt;The transition element.&lt;/value&gt;
        private TransitioningContentControl TransitionElement { get; set; }

        /// &lt;summary&gt;
        /// Occurs when the TransitioningDomainUpDown is incremented.
        /// &lt;/summary&gt;
        public event EventHandler Incremented;

        /// &lt;summary&gt;
        /// Occurs when the TransitioningDomainUpDown is decremented.
        /// &lt;/summary&gt;
        public event EventHandler Decremented;

        /// &lt;summary&gt;
        /// Gets or sets the Style for the TransitioningContentControl.
        /// &lt;/summary&gt;
        public Style TransitioningContentControlStyle
        {
            get { return TransitionElement.Style; }
            set { TransitionElement.Style = value; }
        }

        /// &lt;summary&gt;
        /// Builds the visual tree for the DomainUpDown control when a new
        /// template is applied.
        /// &lt;/summary&gt;
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            TransitionElement = GetTemplateChild("Visualization") as TransitioningContentControl;
        }

        /// &lt;summary&gt;
        /// Called by OnSpin when the spin direction is SpinDirection.Increase.
        /// Will not go beyond the first or last item unless IsCyclic is set.
        /// &lt;/summary&gt;
        protected override void OnIncrement()
        {
            if (TransitionElement != null)
            {
                TransitionElement.Transition = UpTransitionState;
            }
            base.OnIncrement();

            EventArgs args = new EventArgs();
            OnIncremented(args);
        }

        /// &lt;summary&gt;
        /// Raised when the spin direction is SpinDirection.Decrease.
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.EventArgs"/&gt; 
        /// instance containing the event data.&lt;/param&gt;
        protected virtual void OnIncremented(EventArgs e)
        {
            EventHandler handler = Incremented;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        /// &lt;summary&gt;
        /// Called by OnSpin when the spin direction is SpinDirection.Increase.
        /// Will not go beyond the first or last item unless IsCyclic is set.
        /// &lt;/summary&gt;
        protected override void OnDecrement()
        {
            if (TransitionElement != null)
            {
                TransitionElement.Transition = DownTransitionState;
            }
            base.OnDecrement();

            EventArgs args = new EventArgs();
            OnDecremented(args);
        }

        /// &lt;summary&gt;
        /// Raised when the spin direction is SpinDirection.Decrease.
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.EventArgs"/&gt; 
        /// instance containing the event data.&lt;/param&gt;
        protected virtual void OnDecremented(EventArgs e)
        {
            EventHandler handler = Decremented;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        /// &lt;summary&gt;
        /// Decrement the TransitioningDomainUpDown.
        /// &lt;/summary&gt;
        public void Decrement()
        {
            OnDecrement();
        }

        /// &lt;summary&gt;
        /// Increment the TransitioningDomainUpDown.
        /// &lt;/summary&gt;
        public void Increment()
        {
            OnIncrement();
        }
    }
}</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="TransitioningDomainUpDown.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports Microsoft.VisualBasic
Imports System

''' &lt;summary&gt;
''' Implementation of DomainUpDown that uses a TransitioningContentControl
''' it its template.
''' &lt;/summary&gt;
''' &lt;QualityBand&gt;Experimental&lt;/QualityBand&gt;
''' &lt;remarks&gt;Implemented in the sample project. The sample page will set
''' the custom template that this control expects.&lt;/remarks&gt;
Public Class TransitioningDomainUpDown
    Inherits DomainUpDown
    ''' &lt;summary&gt;
    ''' The name of the state that represents a transition effect upwards.
    ''' &lt;/summary&gt;
    Public Const UpTransitionState As String = "UpTransition"

    ''' &lt;summary&gt;
    ''' The name of the state that represents a transition effect downwards.
    ''' &lt;/summary&gt;
    Public Const DownTransitionState As String = "DownTransition"

    ''' &lt;summary&gt;
    ''' Gets or sets the transition element.
    ''' &lt;/summary&gt;
    ''' &lt;value&gt;The transition element.&lt;/value&gt;
    Private privateTransitionElement As TransitioningContentControl
    Private Property TransitionElement() As TransitioningContentControl
        Get
            Return privateTransitionElement
        End Get
        Set(ByVal value As TransitioningContentControl)
            privateTransitionElement = value
        End Set
    End Property

    ''' &lt;summary&gt;
    ''' Builds the visual tree for the DomainUpDown control when a new
    ''' template is applied.
    ''' &lt;/summary&gt;
    Public Overrides Sub OnApplyTemplate()
        MyBase.OnApplyTemplate()

        TransitionElement = TryCast(GetTemplateChild("Visualization"), TransitioningContentControl)
    End Sub

    ''' &lt;summary&gt;
    ''' Called by OnSpin when the spin direction is SpinDirection.Increase.
    ''' Will not go beyond the first or last item unless IsCyclic is set.
    ''' &lt;/summary&gt;
    Protected Overrides Sub OnIncrement()
        If TransitionElement IsNot Nothing Then
            TransitionElement.Transition = UpTransitionState
        End If
        MyBase.OnIncrement()
    End Sub

    ''' &lt;summary&gt;
    ''' Called by OnSpin when the spin direction is SpinDirection.Increase.
    ''' Will not go beyond the first or last item unless IsCyclic is set.
    ''' &lt;/summary&gt;
    Protected Overrides Sub OnDecrement()
        If TransitionElement IsNot Nothing Then
            TransitionElement.Transition = DownTransitionState
        End If
        MyBase.OnDecrement()
    End Sub
End Class</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
  </StackPanel>
</UserControl>
